// pages/setcollector/setcollector.js
var that,
  api = new(require('../../utils/api.js')),
  headimg = api.getimgurl(),
  staticimg = api.getstaticimgurl(),
  QQMapWX = require('../../utils/qqmap-wx-jssdk.js'),
qqmapsdk,
  util = new(require('../../utils/util.js'));
Page({

  /**
   * 页面的初始数据
   */
  data: {
    list:[],
    recycleid:0,
    ordernum:'',
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    that=this;
    console.log(options,'options');
    
    that.setData({recycleid:options.recycleid,ordernum:options.ordernum},()=>{
      that.getdata()
    })
  },
  getdata(){
    let {ordernum}=that.data
    api.getmyuserslist1(ordernum,res=>{
      if(res.data.issuccess==1){
        that.setData({list:res.data.list})
      }
    })
  },
  radioChange(e){
    let {value}=e.detail
    that.setData({
      recycleid:value
    })
  },
  submit(){
    let {recycleid,ordernum}=that.data
    wx.showModal({
      title: '调单',
      content: '确认调单吗？',
      success:function(res){
        if(res.confirm){
          api.setturningtrue({userid:recycleid,ordernum},res=>{
            if(res.data.issuccess==1){
              wx.showToast({
                title: '调单成功',
                icon: 'none',
                duration: 2000
              })
              wx.navigateBack()
            }
          })
         
        }
      },
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})